﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DevFx.FrameWork
{
    /// <summary>
    /// 分页查询信息
    /// </summary>
    [Serializable]
    public class PagerCondition
    {
        public PagerCondition()
        {
            PageSize = int.Parse(System.Configuration.ConfigurationManager.AppSettings["PageSize"].ToString());
            IsPaging = true;
            IsGetRecordCount = true;
        }
        #region 私有变量
        private int _RecordCount = -1;
        private int _PageSize = -1;
        private int _CurrentPage = 1;
        Stack<SortCondition> _SortConditions;
        private bool _IsPaging = true;
        #endregion

        #region 公共属性
        /// <summary>
        /// 是否分页
        /// </summary>
        public bool IsPaging
        {
            get
            {
                return _IsPaging;
            }
            set
            {
                _IsPaging = value;
            }
        }
        /// <summary>
        /// 总记录数
        /// </summary>
        public int RecordCount
        {
            get
            {
                return _RecordCount;
            }
            set
            {
                _RecordCount = value;
            }
        }

        /// <summary>
        /// 总页数
        /// </summary>
        public int PageCount
        {
            get
            {
                if (PageSize >= 0)
                    return ((RecordCount - 1) / PageSize) + 1;
                return 1;
            }

        }

        /// <summary>
        /// 每页记录数
        /// </summary>
        public int PageSize
        {
            get
            {
                return _PageSize;
            }
            set
            {
                _PageSize = value;
            }
        }

        /// <summary>
        /// 当前页
        /// </summary>
        public int CurrentPage
        {
            get
            {
                return _CurrentPage;
            }
            set
            {
                _CurrentPage = value;
            }
        }

        /// <summary>
        /// 是否获取总记录数
        /// </summary>
        public bool IsGetRecordCount
        {
            get;
            set;
        }
        /// <summary>
        /// 当前GridView排序方式
        /// </summary>
        public string GridDirection
        {
            get;
            set;
        }
        /// <summary>
        /// 排序条件列表
        /// </summary>
        public Stack<SortCondition> SortConditions
        {
            get
            {
                if (_SortConditions == null)
                    _SortConditions = new Stack<SortCondition>();

                return _SortConditions;
            }
        }
      
        #endregion
    }
}
